/**
 * @Auther: hjy(lc))
 * @Date: 2022/7/16-07-16-11:40
 * @Description：向enum类添加方法与自定义构造函数
 */
public enum enum_02 {
    MONDAY("星期一"),
    TUESDAY("星期二"),
    WEDNESDAY("星期三"),
    THURSDAY("星期四"),
    FRIDAY("星期五"),
    SATURDAY("星期六"),
    SUNDAY("星期日");

    private String description;  //中文描述
    //私有构造，防止被外部调用
    private  enum_02( String description){
        //System.out.println("enum_02.enum_02");
        this.description=description;
    }

//    public  String getDescription(){
//        return description;
//    }

    @Override
    public String toString() {
        return description ;
    }

    public static void main(String[] args) throws ClassNotFoundException {
        Class.forName("enum_02");   //触发类的初始化，枚举还在静态代码块static{}中初始化了类对象，触发了构造器
        for (enum_02 day : enum_02.values()) {
            //System.out.println("name: " + day.name() + ".description: " + day.getDescription());
            System.out.println("name: " + day.name() + ".description:  " + day.toString());
        }
    }
}
